package com.websocket.controller;

import com.websocket.service.WebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/websocket")
public class WebSocketController {

    //https://websocket.jsonin.com/    测试地址
//http://localhost:8080/websocket/sentMessage?userId=2&message=assssssssssss
    @Autowired
    private WebSocket webSocket;


    @GetMapping("/sentMessage")
    public void sentMessage(String userId, String message) {
        try {
            webSocket.sendMessageByUserId(userId, message);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


}
